package by.grsu.mf;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.Menu;
import android.view.View;
import by.grsu.mf.fragment.FriendsFragment;
import by.grsu.mf.fragment.MessagesFragment;
import by.grsu.mf.fragment.NewsFragment;
import by.grsu.mf.fragment.WallFragment;

public class MainActivity extends FragmentActivity {
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        startActivity(new Intent(this, ApplicationStartActivity.class));
        setContentView(R.layout.activity_main);
        ViewPager pager = (ViewPager) findViewById(R.id.pager);
        pager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
			
			@Override
			public int getCount() {
				return 4;
			}
			
			@Override
			public Fragment getItem(int pageNumber) {
				switch (pageNumber) {
				case 0:
					return new NewsFragment();
				case 1:
					return new WallFragment();

				case 2:
					return new FriendsFragment();
					
				case 3:
					return new MessagesFragment();
	
				default:
					break;
				}
				return null;
			}
			
		});
        pager.setOnPageChangeListener(new OnPageChangeListener() {
			
			@Override
			public void onPageSelected(int pageNumber) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub
				
			}
		});
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    public void onVkLogin(View view) {
    	startActivity(new Intent(this, LoginActivity.class));
    }
    
   
}
